//
//  DocumentView.m
//  KurtulusLaw
//
//  Created by phuc phuc on 12/1/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "DocumentView.h"
#import "DocumentCell.h"
#import "KDocumentDAO.h"
#import "KDocumentDTO.h"
#import "KDocumentCommandDTO.h"
#import "KResponedDocumentCommandDTO.h"
#import "KDocumentCellFactory.h"
@interface DocumentView ()<UITableViewDelegate,UITableViewDataSource>
@end

@implementation DocumentView


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}



- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle


- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self.titleView setText:NSLocalizedString(@"Documents", nil)];
}

- (void)initializeFactory {
	_searchFileDAO = [[KDocumentDAO alloc] init];
	_searchCommandDTO = [[KDocumentCommandDTO alloc] initWithSessionID:[CCommon shareSessionID] ];
	_cellFactory = [[KDocumentCellFactory alloc] init];
	
}


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
	UIView *view = [super tableView:tableView viewForHeaderInSection:section];
	
	// Create label with section title
    UILabel *label = [[UILabel alloc] init] ;
    label.frame = CGRectMake(40, 0, 160, 23);
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont boldSystemFontOfSize:15.0f];
    label.text = NSLocalizedString(@"Document Name", nil);
    label.backgroundColor = [UIColor clearColor];
    [view addSubview:label];
	
	UILabel *label1 = [[UILabel alloc] init] ;
    label1.frame = CGRectMake(210, 0, 130, 23);
    label1.textColor = [UIColor whiteColor];
    label1.font = [UIFont boldSystemFontOfSize:15.0f];
    label1.text = NSLocalizedString(@"Document", nil);
    label1.backgroundColor = [UIColor clearColor];
	[view addSubview:label1];
	
    
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 23;
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
 
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


@end
